<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * 短信接口驱动
 */

class Sms_driver_xunchao extends Sms_driver implements Sms_driver_interface
{
    private $url ="http://121.199.26.214:9890/SmsService/sms/send.do";
    private $setting;
    public function load_config($config)
    {
        $this->setting=$config;
    }

    public function send($mobile,$msg)
    {
        $data['uid'] = base64_encode($this->setting['account']);
        $data['pwd'] = strtoupper(md5($this->setting['password']));
        $data['phones'] =$mobile;
        $data['msg']=base64_encode($msg);
        $options[CURLOPT_TIMEOUT] = $this->setting['timeout'];
        $result =  $this->curl->simple_get($this->url,$data,$options);
        if($result==FALSE)
        {
            return FALSE;
        }
        $ret = array();
        parse_str($result,$ret);
        if(!isset($ret['resCode']) || $ret['resCode']!="100")
        {
            if(isset($ret['resMsg']))
            {
                log_message("debug","phone: ".$mobile." result:".$ret['resMsg']);
            }
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }
}

